package com.taotao.rest.controller;

import com.taotao.common.pojo.TaotaoResult;
import com.taotao.rest.service.ItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品信息Controller
 * <p>Title: ItemController</p>
 * <p>Description: </p>
 * <p>Company: www.itcast.com</p>
 *
 * @author 入云龙
 * @version 1.0
 * @date 2015年9月12日上午10:22:11
 */
@Api(description = "商品")
@RestController
public class ItemController {

    @Autowired
    private ItemService itemService;

    @ApiOperation("通过商品ID获取商品基本信息")
    @GetMapping({"/item/info/{itemId}",
            "/rest/item/info/{itemId}"})
    public TaotaoResult getItemBaseInfo(@PathVariable Long itemId) {
        return itemService.getItemBaseInfo(itemId);
    }

    @ApiOperation("通过商品ID获取商品详情")
    @GetMapping({"/item/desc/{itemId}",
            "/rest/item/desc/{itemId}"})
    public TaotaoResult getItemDesc(@PathVariable Long itemId) {
        return itemService.getItemDesc(itemId);
    }

    @ApiOperation("通过商品ID获取商品参数")
    @GetMapping({"/item/param/{itemId}",
            "/rest/item/param/{itemId}"})
    public TaotaoResult getItemParam(@PathVariable Long itemId) {
        return itemService.getItemParam(itemId);
    }

    @ApiOperation("通过分类ID获取商品列表")
    @GetMapping("/rest/item/cat/{catId}")
    public TaotaoResult getItemByCatId(@PathVariable Long catId) {
        return itemService.getItemByCatId(catId);
    }
}
